Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
eyeekit
Frequent Visitor

Cannot put measure in X-asis or Y-asis in any column chart

Hello i have problems using measures in any bar charts.

 

I created the folowing measure to calculate the age.

Age =

VAR _peildatum=SELECTEDVALUE('Peildata'[datum])
RETURN
DATEDIFF(SELECTEDVALUE(Bezetting[Geboortedatum]),_peildatum,DAY)/365.25
 
I use this measure to create a second measure to define age categories:
Age_Categorie =
VAR lft = Bezetting[Age]
RETURN
SWITCH (TRUE(),
 lft<25,"<25",
 lft<35,"25-<35",
 lft<45,"35-<45",
 lft<55,"45-<55",
 lft<60,"55-<60",
 "60 of meer"
)
 
Now I want to create the folowing barchart to count the people in the diffrent age categories:
eyeekit_0-1700677367956.png

But I cannot put the measures in the X-asis or Y-asis in the barchart .

 

How can I achieve this? Please help.

1 ACCEPTED SOLUTION
eyeekit
Frequent Visitor

Hi all,

 

I did not solve the problem anymore with DAX because of its complexity.

I included the date selection as column in the dataset in SQL and this makes life so much easier....

I use the following SQL code:

 

--Datelist: 1st day of the month starting 2020 untill now
WITH Peildata AS
(
SELECT datum
FROM [biDWH_Presentation].[dm].[dim_Datum]
WHERE jaar >= 2020 AND dag_in_maand=1 AND datum <=GETDATE()
)

--For each record in datelist select data between startdate and enddate
SELECT objectid
,Datum_in_dienst
,Datum_uit_dienst
,Datum
FROM [biDWH_Presentation].[dm_hr].[dim_hrm_dienstverband]
FULL OUTER JOIN Peildata ON datum between Datum_in_dienst AND datum_uit_dienst

 

Thank all for your comments/support/advise. Much appreciated!

View solution in original post

8 REPLIES 8
eyeekit
Frequent Visitor

Hi all,

 

I did not solve the problem anymore with DAX because of its complexity.

I included the date selection as column in the dataset in SQL and this makes life so much easier....

I use the following SQL code:

 

--Datelist: 1st day of the month starting 2020 untill now
WITH Peildata AS
(
SELECT datum
FROM [biDWH_Presentation].[dm].[dim_Datum]
WHERE jaar >= 2020 AND dag_in_maand=1 AND datum <=GETDATE()
)

--For each record in datelist select data between startdate and enddate
SELECT objectid
,Datum_in_dienst
,Datum_uit_dienst
,Datum
FROM [biDWH_Presentation].[dm_hr].[dim_hrm_dienstverband]
FULL OUTER JOIN Peildata ON datum between Datum_in_dienst AND datum_uit_dienst

 

Thank all for your comments/support/advise. Much appreciated!

parry2k
Super User
Super User

@eyeekit thanks for confirming. Greetings from Canada! Check this blog post and also check following video on my channel that can help to get the solution.

 

Mastering Disconnected Tables - Use measures in slicers in Power BI | PeryTUS - Power BI How To - Yo...



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Ritaf1983 100% agree with you, I made that based on this assumption:

 

VAR _peildatum=SELECTEDVALUE('Peildata'[datum])



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k 

I think , we should wait for the author's responce 🤓😊

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi people, greetings from Holland. Thank you all for taking time to look into my case.

It's all dynamic. I choose a date from a datelist slicer and with this I create teh first measaure

to calculate the age. And from this I define the age categories.

 

I want to upload the pbix but i do'n't see any button to do so. How can i upload ?

 

 

parry2k
Super User
Super User

@Ritaf1983 good point but it will not work dynamically, especially in this it looks like it is based on the selected date. With the calculated column you have to work with a fixed date. Just my 2 cents.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

For this scenario, we have a dynamic segmentation....the author didn't provide some data that explains his case entirely...so we can't know...

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
Ritaf1983
Super User
Super User

Hi @eyeekit 
You should use a calculated column instead of the measure for bins.

please refer to the linked tutorial:

https://www.youtube.com/watch?v=PjHgi7X3_Bw

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.