cancel
Showing results for
Did you mean:
Highlighted
Frequent Visitor

## Counting columns on a visual - measure

Hi friends,

I have a table (visual) that can have a variable amount of columns - depending on the filter the user applied. I would like to create a measure which is 40*"number of current columns in the visual".

Can you help?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support

## Re: Counting columns on a visual - measure

Create a date table and create a relationship with your main table.

``````Date =
CALENDARAUTO (),
"year", YEAR ( [Date] ),
"month", MONTH ( [Date] ),
"week", WEEKNUM ( [Date], 2 ),
"year-week", YEAR ( [Date] ) & "-" & "week"
& WEEKNUM ( [Date], 2 )
)
``````

Use the [week] from the date table into a slicer.

Then create measures

``````actual registered = SUM('Table'[registerd hour])

discount weeks = CALCULATE(DISTINCTCOUNT('Date'[year-week]),ALLSELECTED('Date'))

still need = DISTINCTCOUNT('Table'[name id])*40*[discount weeks]-SUMX('Table',[actual registered])``````

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

6 REPLIES 6
Highlighted
Super User IV

## Re: Counting columns on a visual - measure

@campelliann , Not sure I got it. typically number measures are constant in a visual.

The information you have provided is not making the problem clear to me. Can you please explain with an example.

Proud to be a Super User!

Super User II

## Re: Counting columns on a visual - measure

I think you need to create a new table based on the logic of creating that visual table. Then you countrows of the new table.

What's more, you need to provide more details on your questions.

Hope this is helpfu.

Proud a to be a Datanaut!
Thanks and BR
Ryan
Highlighted
Community Support

## Re: Counting columns on a visual - measure

Could you share an example?

Best Regards

Maggie

Highlighted
Frequent Visitor

## Re: Counting columns on a visual - measure

This is basically a timesheet control to assure everyone registers 40h per week. I select a week (e.g. 5 june) and calculate a measure for the hours yet to be registered - graph at the right.  I want the formula to be Hours missing = Number of people x 40 x number of weeks selected - total hours registered in the week/weeks selected

If I select the week 5 june alone, or 12 june alone, the formula works. But if I select both weeks (or more) it doesnt - because the measure i created is for 40 hours per person (doesnt take into account the number of weeks/columns in the filter).

Suming up: if the filter is on 1 week, each person must register 40 h. If in two weeks 80 h etc.

Highlighted
Community Support

## Re: Counting columns on a visual - measure

Create a date table and create a relationship with your main table.

``````Date =
CALENDARAUTO (),
"year", YEAR ( [Date] ),
"month", MONTH ( [Date] ),
"week", WEEKNUM ( [Date], 2 ),
"year-week", YEAR ( [Date] ) & "-" & "week"
& WEEKNUM ( [Date], 2 )
)
``````

Use the [week] from the date table into a slicer.

Then create measures

``````actual registered = SUM('Table'[registerd hour])

discount weeks = CALCULATE(DISTINCTCOUNT('Date'[year-week]),ALLSELECTED('Date'))

still need = DISTINCTCOUNT('Table'[name id])*40*[discount weeks]-SUMX('Table',[actual registered])``````

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Frequent Visitor

## Re: Counting columns on a visual - measure

Still a newbie here. It was not that hard 🙂

Many thanks!

Announcements

#### Power Platform Community Conference

Check out the on demand sessions that are available now!

#### Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

#### Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors